package com.doit.day01;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;

public class _03_迭代器测试 {
    public static void main(String[] args) {
        //底层是一个数组
        ArrayList<Integer> list = new ArrayList<>();
        list.add(0);
        list.add(2);
        list.add(1);
        list.add(4);
        list.add(6);

        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }

        //底层是一个hash表
        HashSet<Integer> set = new HashSet<>();
        set.add(0);
        set.add(2);
        set.add(1);
        set.add(4);
        set.add(6);

        Iterator<Integer> iterator1 = set.iterator();
        while (iterator1.hasNext()){
            System.out.println(iterator1.next());
        }



    }
}
